local s15__zhiji = fk.CreateSkill {
  name = "s15__zhiji",
  tags = { Skill.Wake },
}

Fk:loadTranslationTable {
  ["s15__zhiji"] = "志继",
  [":s15__zhiji"] = "觉醒技，准备阶段或结束阶段，若你没有手牌，你回复1点体力或摸两张牌，减1点体力上限，然后获得〖观星〗。",

  ["$s15__zhiji1"] = "先帝之志，丞相之托，不可忘也！",
  ["$s15__zhiji2"] = "丞相厚恩，维万死不能相报。",
}

s15__zhiji:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(s15__zhiji.name) and
        player:usedSkillTimes(s15__zhiji.name, Player.HistoryGame) == 0 and
        (player.phase == Player.Start or player.phase == Player.Finish)
  end,
  can_wake = function(self, event, target, player, data)
    return player:isKongcheng()
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = { "draw2" }
    if player:isWounded() then
      table.insert(choices, "recover")
    end
    local choice = room:askToChoice(player, {
      choices = choices,
      skill_name = s15__zhiji.name,
    })
    if choice == "draw2" then
      player:drawCards(2, s15__zhiji.name)
    else
      room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = s15__zhiji.name
      })
    end
    if player.dead then return end
    room:changeMaxHp(player, -1)
    if player.dead then return end
    room:handleAddLoseSkills(player, "s15__guanxing", nil, true, false)
  end,
})

return s15__zhiji
